IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spCdsNCreatePerEmployeeStatusType')
	BEGIN
		PRINT 'Dropping Procedure spCdsNCreatePerEmployeeStatusType    '
		DROP  Procedure  spCdsNCreatePerEmployeeStatusType    
	END

GO

PRINT 'Creating Procedure spCdsNCreatePerEmployeeStatusType'
GO
/******************************************************************************
**		VSS File: $/spCdsNCreatePerEmployeeStatusType.sql 
**		Name: spCdsNCreatePerEmployeeStatusType    
**		Desc: 	This procedure creates a record in the 
**				PerEmployeeStatusType table
**              
**		Return values: None
** 
**		Called by:   
**              
*******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:				Description:
**		--------		--------				-------------------------------------------
**    
*******************************************************************************/
CREATE Procedure spCdsNCreatePerEmployeeStatusType (
	/* Param List */
	@name				VARCHAR(256),
	@description		VARCHAR(512)
)	   
AS    

BEGIN 

	SET NOCOUNT ON

	DECLARE @_errorCode					INT
	DECLARE @_perEmployeeStatusTypeId	INT

	SET @_errorCode  = 0


	-- Setup the IDs to be inserted by selecting the max
	-- Id of the column, and if null, start at 1.
	SET @_perEmployeeStatusTypeId = COALESCE( ((SELECT MAX(Id) FROM PerEmployeeStatusType)+1), 1)

	-- Insert the PerEmployeeStatusType
	INSERT INTO PerEmployeeStatusType	 (	Id, 
								Name, 
								Description,
								DateCreated ) 
	VALUES
							 (	@_perEmployeeStatusTypeId, 
								@name,	
								@description,
								GETDATE() )
	
	SET @_errorCode = @@ERROR

    IF @_errorCode <> 0 BEGIN
           RAISERROR('Unable to create PerEmployeeStatusType record for PerEmployeeStatusType %s', 16, 1, @name)
           RETURN @_errorCode
    END

END

GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
  